<template name="goodsTable">
	<el-table :data="goodsList" :height="getWinHeight" border style="width: 100%" :row-style="{cursor:'pointer'}" highlight-current-row @selection-change="tableSelectChange">
	<el-table-column
		type="selection"
		align="center"
		width="40">
	</el-table-column>
	<el-table-column
		label="商品图片"
		align="center"
		width="100">
		<template scope="scope">
			<img :src="scope.row.head_img" width="80" height="80"/>
		</template>
	</el-table-column>
	<el-table-column
		prop="product_name"
		label="商品名称"
		align="center">
	</el-table-column>
	<el-table-column
		prop="price"
		align="center"
		label="价格"
		width="80">
	</el-table-column>
	<el-table-column
		prop="unit"
		align="center"
		label="单位"
		width="80">
	</el-table-column>
	<el-table-column
		prop="buy_num"
		label="销量"
		align="center"
		width="70">
	</el-table-column>
	<el-table-column
		prop="status"
		label="状态"
		width="80"
		align="center">
		<template slot-scope="scope">
			<span v-if="scope.row.status==='0'">待审核</span>
			<span v-if="scope.row.status==='1'">已上架</span>
			<span v-if="scope.row.status==='2'">未上架</span>
			<span v-if="scope.row.status==='3'">审核不通过</span>
			<span v-if="scope.row.status == 4">回收站</span>
        </template>
		</el-table-column>
		<el-table-column
			label="操作"
			align="center"
			width="400">
			<template slot-scope="scope">
				<el-button
					size="mini"
					@click="handleSee(scope.$index, scope.row)">查看</el-button>
				<el-button
					size="mini"
					@click="handleCheck(scope.$index,scope.row)"  v-if="scope.row.status==='0'">
					审核
				</el-button>
			</template>
		</el-table-column>
    </el-table>
</template>

<script>
export default {
    name: 'goodsTable',
    props: ['goodsList'],
    data() {
      return {
      }
    },
    computed:{
        getWinHeight(){
            let winHeight = document.body.clientHeight;
            return winHeight - 320
        }
    },
    methods:{
      handleSee(index,row){
        this.$router.push({
          path: '/fx_goods_details',
          query: {
            type: 1,
            id: row.id
          }
        })
      },
      async operationGoods(list){
        let res = await this.$Http.operationGoods({
            type: 3,
            id: list.id
        })
        console.log(res)
        if(res.code == 1){
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
          this.$emit('refreshTableFun')
        }else{
          this.$message({
            type: 'warning',
            message: '删除失败! 请重新尝试'
          });
        }
      },
		tableSelectChange(val) {
			console.log(val)
			this.$emit('tableSelectChange',val)
		},
		handleCheck(index,row){
			this.$router.push({
			path: '/fx_goods_details',
			query: {
				type: 2,
				id: row.id
				}
			})
		},
    },

}
</script>

<style>
</style>
